I am getting a weird error while using React and Redux
I access data from redux state using the following code:
const aboutGet = useSelector((state) => state.aboutGet);
const { loading, error, aboutData } = aboutGet;
console.log(aboutData);
The output of the above is the console output as follows:
[{…}]
0:
aboutcontent: "Test Data"
createdAt: "2021-09-19T08:59:01.548Z"
image: "Some Image"
title: "Some new About"
updatedAt: "2021-09-20T03:04:09.014Z"
__v: 0
_id: "6146fbd5f4720923359e3338"
[[Prototype]]: Object
length: 1
I now start by trying to access the _id from the above by using the following lines of code:
const aboutId = aboutData[0]._id;
console.log(aboutId);
This gives me the following error:
"TypeError: Cannot read properties of undefined (reading '0')"
Can someone please help and let me know where I am going wrong and what I need to do to access the data inside aboutData.
Many thanks and regards Teejay